package com.mrper.util;

import android.os.Bundle;
import android.support.v4.app.Fragment;

/**
 * Created by Administrator on 2016/8/23.
 * 视图控件辅助类
 */
public class ViewUtil {

    /**
     * 获取Fragment实例
     * @param tClass Fragment类
     * @param argument fragment的参数，可为null
     */
    public static <T extends Fragment> T getFragmentInstance(Class<T> tClass, Bundle argument){
        try {
            T instance = tClass.newInstance();
            if(argument != null)
                instance.setArguments(argument);
            return instance;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

}
